import com.mysql.jdbc.MySQLConnection;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws SQLException {

        DataSource dataSource=new MysqlDataSource();
        ((MysqlDataSource) dataSource).setURL("jdbc:mysql://127.0.0.1:3306/java112?characterEncoding=utf8&useSSL=false");
        ((MysqlDataSource) dataSource).setUser("root");
        ((MysqlDataSource) dataSource).setPassword("222222");

        Connection connection= dataSource.getConnection();

        //String sql="insert into student values(?,?)";
        String sql="insert into student values(1,'张三')";
        PreparedStatement statement =connection.prepareStatement(sql);


        int n=statement.executeUpdate();
        System.out.println(n);

        statement.close();
        connection.close();
    }
}
